package com.example.homeworkrabbitmq.repository;

import com.example.homeworkrabbitmq.entity.Order;
import com.example.homeworkrabbitmq.enums.OrderStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface OrderRepository extends JpaRepository<Order,Integer> {

    @Modifying
    @Query(nativeQuery = true,value = "UPDATE order_info \n" +
            "SET order_status = :#{#order.orderStatus.ordinal()},update_time = :#{#order.updateTime}\n" +
            "where order_no=:#{#order.orderNo}")
    public int updateStatus(@Param("order") Order order);
}
